package com.shoeshopping.action.zx;

import javax.annotation.Resource;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
import com.shoeshopping.formbean.zx.GoodsAdminForm;
import com.shoeshopping.formbean.zx.OrderAdminForm;
import com.shoeshopping.service.zx.OrderAdminService;
import com.shoeshopping.utils.zx.EasyUIResult;
import com.shoeshopping.utils.zx.JsonUtil;
import com.shoeshopping.utils.zx.Result;
import com.shoeshopping.vo.zx.VoOrderAdmin;

@Controller("orderAdminAction")
@Scope("prototype")
public class OrderAdminAction extends ActionSupport implements ModelDriven<OrderAdminForm>{

	OrderAdminForm dataForm = new OrderAdminForm();
	
	VoOrderAdmin orderAdmin;
	
	@Resource
	OrderAdminService orderAdminService;
	
	public void list(){
		EasyUIResult result = null;
		try{
			result = orderAdminService.list(dataForm);
		} finally{
			JsonUtil.output(result);
		}
	} 
	
	public String edit(){
		orderAdmin  = orderAdminService.edit(dataForm);
		if(orderAdmin != null){
			return Result.EDIT;
		}
		return Result.ERROR;
	}
	
	public void delete(){
		orderAdminService.delete(dataForm);
		JsonUtil.output(Result.success());
	}
	
	public String add(){
		if(orderAdminService.add(dataForm)){
			return Result.SUCCESS;
		}
		return Result.ERROR;
	}
	
	public void listItem(){
		EasyUIResult result = null;
		try{
			result = orderAdminService.listItem(dataForm);
		} finally{
			JsonUtil.output(result);
		}
	}
	
	@Override
	public OrderAdminForm getModel() {
		return dataForm;
	}
	
	public VoOrderAdmin getOrderAdmin() {
		return orderAdmin;
	}

	public void setOrderAdmin(VoOrderAdmin orderAdmin) {
		this.orderAdmin = orderAdmin;
	}

}
